<?php
/**
 * Пример ручной настроки grid
 */

// проверка если установлен вывод выводим его иначе все что ниже даного блока if
if($this->grid !== null) {
     echo $this->grid;
     return;
}
?>

<?php 
$idGrid = 'list';
$idPgrid = 'plist';
?>
<link rel="stylesheet" type="text/css" media="screen" href="/scripts/jquery/plugins/jgGrid/css/smoothness/jquery-ui-1.7.2.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="/scripts/jquery/plugins/jgGrid/css/ui.multiselect.css" />
<link rel="stylesheet" type="text/css" media="screen" href="/scripts/jquery/plugins/jgGrid/css/ui.jqgrid.css" />

<table id="<?php echo $idGrid;?>"></table> 
<div id="<?php echo $idPGrid;?>"></div>

<script type="text/javascript" src="/scripts/jquery/plugins/jgGrid/js/i18n/grid.locale-ru.js"></script>
<script type="text/javascript" src="/scripts/jquery/plugins/jgGrid/js/jquery.jqGrid.min.js"></script>

    <script type="text/javascript">
    jQuery(document).ready(function(){
        var lastSel;
        jQuery("#<?php echo $idGrid;?>").jqGrid({
            url:'<?php echo $this->url();?>',
            datatype: 'json',
            mtype: 'POST',
            colNames:['#', 'Фамилия', 'Имя', 'Отчество'],
            colModel :[
                {name:'id', index:'id', width:50, align:'right', search:false},
                {name:'login', index:'login', width:150, align:'right', editable:true, edittype:"text", searchoptions:{sopt:['eq','ne','bw','cn']}},
                {name:'initial', index:'initial', width:150, align:'right', editable:true, edittype:"text", searchoptions:{sopt:['eq','ne','bw','cn']}},
                {name:'country', index:'country', width:150, align:'right', editable:true, edittype:"select", searchoptions:{sopt:['eq','ne','bw','cn']}, editoptions:{value:"FE:FedEx;IN:InTime;TN:TNT;AR:ARAMEX"}}
                ],
            width:700,            
            pager: jQuery('#<?php echo $idPgrid;?>'),
            rowList:[5,10,20,30,50,100],
                        sortname: 'id',
            sortorder: "asc",
                        viewrecords: true,
                                    ondblClickRow: function(id) {
                jQuery("#<?php echo $idGrid;?>").restoreRow(lastSel);
                jQuery("#<?php echo $idGrid;?>").editRow(id, true);
                lastSel = id;
            },
            onSelectRow: function(id) {
                jQuery("#<?php echo $idGrid;?>").restoreRow(lastSel);
            },
            editurl: '<?php echo $this->url();?>',
                        rowNum:1        });
                    jQuery("#<?php echo $idGrid;?>").navGrid('#<?php echo $idPgrid?>',{view:true,del:true,add:true,edit:true}, 
                {}, //  default settings for edit
                {}, //  default settings for add
                {},  // delete instead that del:false we need this
                {closeOnEscape:true, multipleSearch:true, closeAfterSearch:true}, // search options
                {} /* view parameters*/
            ); 
        }); 

    </script>